import MyMLDataSource
import TreeModel
#import KNNModule
#import SortMoudle

#python类的多继承测试
#region python类的多继承测试
##class A:
##    def __init__(self):
##        print("A init")
        
##class B:
##    def __init__(self):
##        print("B init")
##class C:
##    def __init__(self):
##        print("C init")

##class D(B,A,C):
##    def Show(self):
##        print("D.Show")
##    i = 5

###d = D()
####d.Show()
###print(d.i)
###d.Show()
#endregion



##data = MyMLDataSource.ModuleTestData.GetDataForKNN_01()
#####print(data)
##one_KNNMachine = KNNModule.KNNMachine()
##one_KNNMachine.Training(data);
###one_KNNMachine.Predict([5,8]);
###one_KNNMachine.Predict([2,5]);
##one_KNNMachine.Predict([2,5],50);


##平衡二叉树测试
#import TreeModel
#arr = MyMLDataSource.ModuleTestData.GetArr()

#blanceBinaryTree = TreeModel.MyBinaryTree.CreateBlanceBinaryTree(arr)
#TreeModel.PreOrder(blanceBinaryTree)
#print("Stop Here")


# 平衡二叉树测试
# region 创建平衡二叉树测试

#print("创建平衡二叉树测试 Start!")
#list = MyMLDataSource.ModuleTestData.GetArrForTree()
#root = None
#i = 0
#while(i<len(list)):
#    nodeTemp = TreeModel.TreeNode(list[i])
#    root =  TreeModel.MyBinaryTree.AddNodeInBlanceSearchTree(root,nodeTemp)
#    i = i+1
#    TreeModel.PrintTree(root)
#    if i<len(list):
#        print("Next one:%d"%(list[i]))
#    print("------------------------------------")
#print("创建平衡二叉树测试 End")

#print("平衡二叉树节点删除测试 Start")
#while(root!=None):
#    TreeModel.PrintTree(root)
#    delNum = input("请输入要删除的数(输入q退出)")
#    if delNum == "q":
#        break
#    nodeTemp = TreeModel.TreeNode(int(delNum))
#    root = TreeModel.MyBinaryTree.DelNode(nodeTemp,root)
#    print("------------------------------------")

#print("平衡二叉树节点删除测试 End")

#endregion

#完全二叉树测试
#region
#aTree = TreeModel.TreeBase();
#arr = MyMLDataSource.ModuleTestData.GetArr();
#aTree.CreateTree(arr)
#aTree.PrintTree();
#print("先序遍历：",end = "")
#aTree.PreOrder();
#print("")
#print("中序遍历：",end = "")
#aTree.MidOrder();
#print("")
#print("后序遍历：",end = "")
#aTree.PostOrder();
#print("")
#print("End ")
#endregion

#哈夫曼树测试
#region
#aHuffManTree = TreeModel.HuffManTree();
#arr = MyMLDataSource.ModuleTestData.GetArr();
#aHuffManTree.CreateTree(arr)
#aHuffManTree.PrintTree();
#print("先序遍历：",end = "")
#aHuffManTree.PreOrder();
#print("")
#print("中序遍历：",end = "")
#aHuffManTree.MidOrder();
#print("")
#print("后序遍历：",end = "")
#aHuffManTree.PostOrder();
#print("")
#print("End ")
#endregion
import TreeModelV2

aBinaryTree = TreeModelV2.MyBinaryTree()
#list = MyMLDataSource.ModuleTestData.GetArrForTree()
#root = None
#i = 0
#while(i<len(list)):
#    nodeTemp = TreeModel.TreeNode(list[i])
#    root =  TreeModel.MyBinaryTree.AddNodeInBlanceSearchTree(root,nodeTemp)
#    i = i+1
#    TreeModel.PrintTree(root)
#    if i<len(list):
#        print("Next one:%d"%(list[i]))
#    print("------------------------------------")
#print("Before End")

#root = TreeModel.TestTree()
#root = TreeModel.TestTree_2()
#TreeModel.LevelOrder(root)
#TreeModel.PrintTree(root)
#print("%5s,%s"%(10,10))
import matplotlib
import matplotlib.pyplot as plt
import KNNModule

data = MyMLDataSource.ModuleTestData.GetDataForKNN_01()
###print(data)
one_KNNMachine = KNNModule.KNNMachine()
one_KNNMachine.Training(data);

pointInfo = []
i=0;
j=0
while(i<15):
    print(i)
    while(j<6):
        colorInt = one_KNNMachine.Predict([i,j],50);
        color = 'r'
        if colorInt == 1:
            color = 'r'
        else:
            if colorInt == 2:
                color = 'yellow'
            else:
                if colorInt == 3:
                    color = 'lime'
                else:
                    if colorInt == 4:
                        color = 'slategray'
                    else:
                        if colorInt == 5:
                            color = 'b'
                        else:
                            if colorInt == 6:
                                color ='magenta'

        #pointInfo.append([i,j,color])
        plt.scatter(i,j,c=color,alpha = 0.4)
        j=j+0.3
        #print(i,j)
    i = i + 0.3
    j = 0

index = 0
while(index<len(data)):
    colorInt = data[index][1]
    color = 'r'
    if colorInt == 1:
        color = 'r'
    else:
        if colorInt == 2:
            color = 'yellow'
        else:
            if colorInt == 3:
                color = 'lime'
            else:
                if colorInt == 4:
                    color = 'slategray'
                else:
                    if colorInt == 5:
                        color = 'b'
                    else:
                        if colorInt == 6:
                            color ='magenta'
    plt.scatter(data[index][0][0],data[index][0][1],c=color,alpha = 1)
    index=index +1
#plt.scatter(10,5)
plt.show()